-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SM-386 #185
SM-386 #185
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good only minors
|
||
function getUnclaimedReward(address node, address user, uint256 cycle) external view returns (uint256) { | ||
return _getUnclaimedReward(node, user, cycle); | ||
} | ||
|
||
function _getUnclaimedReward(address node, address user, uint256 cycle) internal view returns (uint256) { | ||
if (claims[node][user][cycle]) { | ||
return 0; | ||
} | ||
|
||
return _getClaim(node, user, cycle); | ||
} | ||
|
||
function getUnclaimedRewards(address node, address user, uint256[] calldata cycles) external view returns (uint256[] memory) { | ||
uint256 [] memory unclaimedRewards = new uint256[](cycles.length); | ||
|
||
for (uint256 i = 0; i < cycles.length; i++) { | ||
unclaimedRewards[i] = _getUnclaimedReward(node, user, cycles[i]); | ||
} | ||
|
||
return unclaimedRewards; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
function getUnclaimedReward(address node, address user, uint256 cycle) external view returns (uint256) { | |
return _getUnclaimedReward(node, user, cycle); | |
} | |
function _getUnclaimedReward(address node, address user, uint256 cycle) internal view returns (uint256) { | |
if (claims[node][user][cycle]) { | |
return 0; | |
} | |
return _getClaim(node, user, cycle); | |
} | |
function getUnclaimedRewards(address node, address user, uint256[] calldata cycles) external view returns (uint256[] memory) { | |
uint256 [] memory unclaimedRewards = new uint256[](cycles.length); | |
for (uint256 i = 0; i < cycles.length; i++) { | |
unclaimedRewards[i] = _getUnclaimedReward(node, user, cycles[i]); | |
} | |
return unclaimedRewards; | |
} | |
function getUnclaimedReward(address node, address user, uint256 cycle) external view returns (uint256) { | |
return _getUnclaimedReward(node, user, cycle); | |
} | |
function getUnclaimedRewards(address node, address user, uint256[] calldata cycles) external view returns (uint256[] memory) { | |
uint256 [] memory unclaimedRewards = new uint256[](cycles.length); | |
for (uint256 i = 0; i < cycles.length; i++) { | |
unclaimedRewards[i] = _getUnclaimedReward(node, user, cycles[i]); | |
} | |
return unclaimedRewards; | |
} | |
function _getUnclaimedReward(address node, address user, uint256 cycle) internal view returns (uint256) { | |
if (claims[node][user][cycle]) { | |
return 0; | |
} | |
return _getClaim(node, user, cycle); | |
} |
); | ||
|
||
for (const [i, r] of unclaimedRewards.entries()) { | ||
expect(r).to.be.eq(BigInt(i + 1) * rewardAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
expect(r).to.be.eq(BigInt(i + 1) * rewardAmount); | |
expect(r).to.be.equal(BigInt(i + 1) * rewardAmount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .eq
is not ambiguous at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a small PR that adds the following methods to the
RewardsManager
contract.getClaim
getUnclaimedReward
getUnclaimedReward
These methods make it easier for clients to determine if a user has an unclaimed reward for a given cycle.